package code

import (
	"fmt"
)

func Array3() {
	var slice []int = []int{0, 0, 0}
	changeSliceArray(slice)
	fmt.Printf("slice: %v\n", slice)

	// make(类型, 长度, 容量)
	// 切片
	var slice2 []int = make([]int, 2, 5)
	fmt.Printf("len(slice2): %v\n", len(slice2))
	fmt.Printf("cap(slice2): %v\n", cap(slice2))
	s2 := slice2[0:3]
	fmt.Printf("s2: %v\n", s2)

	// 指针
	s3 := new([]int)
	s4 := *new([]int)
	fmt.Println(slice2, s3, s4)
}

func Array4() {
	var numbers4 = [...]int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}
	myslice := numbers4[4:6]
	fmt.Printf("myslice为%d， 其长度为：%d\n", myslice, len(myslice))
	myslice = myslice[:cap(myslice)]
	fmt.Printf("myslice的第四个元素为：%d\n", myslice[3])
}
